Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2EventCenter = require("EventCenter");
var def_VIVO_BannerMgr = /* */function () {
  function _ctor() {
    babel_classCallCheck(this, _ctor);
    this.OnShowCallback = new Map();
    this.OnDestroyCallback = new Map();
    this.OnHideCallback = new Map();
    this.bannerAds = new Map();
    this.rects = new Map();
    this.isDestroy = true;
    this.isError = false;
    this.showing = "";
    this.hiding = false;
  }
  return babel_createClass(_ctor, [{
    key: "Init",
    value: function Init(e) {
      this.bannerId = e;
    }
  }, {
    key: "Create",
    value: function Create(e, t) {
      if (window.qg.getSystemInfoSync().platformVersionCode <= 1050) {
        console.log("快应用平台版本号低于1050，暂不支持banner API");
      } else {
        console.log("vivo bannerID:", e);
        if (window.qg && !this.bannerAds.has(e)) {
          var _t70 = window.qg.createBannerAd({
            posId: e,
            style: {},
            adIntervals: 30
          });
          _t70.onLoad(function (e) {
            console.log("banner onLoad", e);
          });
          _t70.onError(function (e) {
            console.log("banner onError", e);
          });
          _t70.onResize(function () {});
          this.bannerAds.set(e, _t70);
        }
      }
    }
  }, {
    key: "CreateAndShow",
    value: function CreateAndShow(e, t) {
      this.Create(e, t);
      this.Show(e, t);
    }
  }, {
    key: "refreshAD",
    value: function refreshAD(e, t) {
      console.log(t);
      this.Destroy(e);
      null != t && this.rects.delete(e);
      this.CreateAndShow(e, t);
    }
  }, {
    key: "Show",
    value: function Show(e, t) {
      var _this141 = this;
      console.log("show bannerID", e);
      if (this.bannerAds.has(e)) {
        this.hiding = false;
        this.bannerAds.get(e).show().then(function () {
          _this141.hiding && _this141.Hide(e);
          console.log("广告显示成功");
          $2EventCenter.default.postEvent("bannershow");
        }).catch(function (e) {
          console.log("广告组件出现问题", e);
        });
        "" == this.showing && (this.showing = e);
        this.OnShowCallback.has(e) && this.OnShowCallback.get(e)();
      } else {
        window.qg && this.CreateAndShow(e, t);
      }
    }
  }, {
    key: "Hide",
    value: function Hide(e) {
      this.hiding = true;
      if (this.bannerAds.has(e)) {
        this.bannerAds.get(e).hide();
        this.showing == e && (this.showing = "");
        this.OnHideCallback.has(e) && this.OnHideCallback.get(e)();
      }
    }
  }, {
    key: "tempHide",
    value: function tempHide() {
      console.log("tempHide", this.showing);
      if ("" != this.showing && this.bannerAds.has(this.showing)) {
        this.bannerAds.get(this.showing).hide();
        this.OnHideCallback.has(this.showing) && this.OnHideCallback.get(this.showing)();
      }
    }
  }, {
    key: "tempShow",
    value: function tempShow() {
      "" != this.showing && this.Show(this.showing);
    }
  }, {
    key: "Destroy",
    value: function Destroy(e) {
      if (this.bannerAds.has(e)) {
        this.showing == e && (this.showing = "");
        this.OnDestroyCallback.has(e) && this.OnDestroyCallback.get(e)();
        this.bannerAds.get(e).offLoad(function (e) {
          console.log(e);
        });
        this.bannerAds.get(e).offError(function (e) {
          console.log(e);
        });
        this.bannerAds.get(e).offResize(function (e) {
          console.log(e);
        });
        this.bannerAds.get(e).destroy();
        this.bannerAds.delete(e);
      }
    }
  }, {
    key: "RealWidth",
    get() {
      return 0;
    }
  }, {
    key: "RealHeight",
    get() {
      return 0;
    }
  }], [{
    key: "Instance",
    get() {
      _ctor._instance || (_ctor._instance = new _ctor());
      return _ctor._instance;
    }
  }]);
}();
exports.default = def_VIVO_BannerMgr;